import request from '@/router/axios';
import {downloadExcel} from '@/router/axios';
import {formatCondition} from '@/util/util';
//单条查询
export const querySysRole = (params) => {
  params.head.transCode = 'querySysRole';
  return request({
    url: '/platform/sysRole/querySysRole',
    method: 'post',
    data: params
  })
}
//多条列表查询，支持条件查询
export const querySysRoleListPage = (params) => {
  params.head.transCode = 'querySysRoleListPage';
  return request({
    url: '/platform/sysRole/querySysRoleListPage',
    method: 'post',
    data: params
  })
}
//按分组查询角色列表
export const querySysRoleTree = (params) => {
  params.head.transCode = 'querySysRoleTree';
  return request({
    url: '/platform/sysRole/querySysRoleTree',
    method: 'post',
    data: params
  })
}
//根据用户id查角色列表
export const querySysRoleListByUserId = (params) => {
  params.head.transCode = 'querySysRoleListByUserId';
  return request({
    url: '/platform/sysRole/querySysRoleListByUserId',
    method: 'post',
    data: params
  })
}
//根据用户组id查角色列表
export const querySysRoleListByGroupId = (params) => {
  params.head.transCode = 'querySysRoleListByGroupId';
  return request({
    url: '/platform/sysRole/querySysRoleListByGroupId',
    method: 'post',
    data: params
  })
}
//新增单条记录
export const saveSysRole = (params) => {
  params.head.transCode = 'saveSysRole';
  return request({
    url: '/platform/sysRole/saveSysRole',
    method: 'post',
    data: params
  })
}
//新增多条记录
export const saveSysRoleList = (params) => {
  params.head.transCode = 'saveSysRoleList';
  return request({
    url: '/platform/sysRole/saveSysRoleList',
    method: 'post',
    data: params
  })
}
//新增或修改单条记录
export const saveOrUpdateSysRole = (params) => {
  params.head.transCode = 'saveOrUpdateSysRole';
  return request({
    url: '/platform/sysRole/saveOrUpdateSysRole',
    method: 'post',
    data: params
  })
}


//新增或修改单条记录
export const saveOrUpdateSysRoleList = (params) => {
  params.head.transCode = 'saveOrUpdateSysRoleList';
  return request({
    url: '/platform/sysRole/saveOrUpdateSysRoleList',
    method: 'post',
    data: params
  })
}

//修改单条记录
export const updateSysRole = (params) => {
  params.head.transCode = 'updateSysRole';
  return request({
    url: '/platform/sysRole/updateSysRole',
    method: 'post',
    data: params
  })
}

//删除单条记录
export const deleteSysRole = (params) => {
  params.head.transCode = 'deleteSysRole';
  return request({
    url: '/platform/sysRole/deleteSysRole',
    method: 'post',
    data: params
  })
}

//删除多条记录
export const deleteSysRoleList = (params) => {
  params.head.transCode = 'deleteSysRoleList';
  return request({
    url: '/platform/sysRole/deleteSysRoleList',
    method: 'post',
    data: params
  })
}
//导出excel
export const exportSysRoleExcel = (params) => {
  downloadExcel({
    url: '/platform/sysRole/excelDownload/exportSysRoleExcel',
    method: 'get',
    data: 
    {
      tenantId: params.head.tenantId,
      projectId: params.body.singleBody.projectId,
      orders:'',
      condition: formatCondition(params.body.sqlCondition)
    }
  })
}
